package com.gitee.huxing.course.conc.conc02.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc.conc02.threadpool
 * @ClassName: NewFixedThreadPoolDemo
 * @Author: huxing
 * @DateTime: 2021-08-25 下午4:44
 */
public class NewFixedThreadPoolDemo {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(16);
        for (int i = 0; i < 100; i++) {
            final int no = 1;
            executorService.execute(()->{
                try {
                    System.out.println("start:" + no);
                    Thread.sleep(1000L);
                    System.out.println("end:" + no);
                } catch (InterruptedException ex){
                    ex.printStackTrace();
                }
            });
        }
        executorService.shutdown();
        System.out.println("Main Thread End");
    }
}
